﻿@model NCP.Recruiting.WebApp.Models.ResumePrviewModel
@{
    ViewBag.Title = "Priview";
}
<script type="text/javascript">
    $(document).ready(function () {
        // 简历回复
        $('.receiptForm').dialog({
            autoOpen: false,
            height: 400,
            width: 460,
            modal: true,
            buttons: {
                "回复": function () {
                    $.ajax({
                        url: '@Url.Action("ResumeReply")',
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            Id: $('#hidId').val(),
                            Jobseekers: $('#hidJobseekers').val(),
                            Subject: $('#hidSubject').val(),
                            Message: $('#hidMessage').val(),
                        }),
                        success: function (result) {
                            if (result) {
                                alert("简历回复成功！");
                            }
                            else {
                                alert("简历回复失败，请重试！");
                            }
                        },
                        error: function (result) {
                            alert("简历回复失败，请重试！");
                        }

                    });

                    $(this).dialog("close");
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                $(this).dialog("close");
            }
        });

        // 邀请面试
        $('.interviewForm').dialog({
            autoOpen: false,
            height: 450,
            width: 460,
            modal: true,
            buttons: {
                "发送": function () {
                    $.ajax({
                        url: '@Url.Action("InvitedToInterview")',
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            Id: $('#hidId').val(),
                            InterviewJobseekers: $('#hidInterviewJobseekers').val(),
                            InterviewDate: $('#hidInterviewDate').val(),
                            InterviewTime: $('#hidInterviewTime').val(),
                            InterviewLocation: $('#hidInterviewLocation').val(),
                            InterviewBody: $('#hidInterviewBody').val(),
                            InterviewSubject: $('#hidInterviewSubject').val(),
                        }),
                        success: function (result) {
                            if (result) {
                                alert("邀请面试成功！");
                            }
                            else {
                                alert("邀请面试失败，请重试！");
                            }
                        },
                        error: function (result) {
                            alert("邀请面试失败，请重试！");
                        }

                    });

                    $(this).dialog("close");
                },
                "取消": function () {
                    $(this).dialog("close");
                }
            },
            close: function () {
                $(this).dialog("close");
            }
        });

        $('#btnResumeReply').bind('click', function () {
            $('.receiptForm').dialog("open");
            return false;
        });

        $('#btnInterview').bind('click', function () {
            $('.interviewForm').dialog("open");
            return false;
        });

        $('#btnPrve').bind('click', function () {
            $('#hidType').val('0');
            $('#btnPrveOrNext').click();
            return false;
        });
        $('#btnNext').bind('click', function () {
            $('#hidType').val('1');
            $('#btnPrveOrNext').click();
            return false;
        });

        // 获取简历回复获取模版信息
        $('.ReplyTemplate').change(function () {
            var id = $(this).val();
            if (id == "00000000-0000-0000-0000-000000000000") {
                return false;
            }
            var hidMessage = $(this).parent().parent().find('#hidMessage');
            var text = hidMessage.val();
            if (text != null && text != "") {
                if (!confirm("已经有邮件内容，确定要替换吗？")) {
                    return false;
                }
            }

            $.ajax({
                url: '@Url.Action("GetTemplateContent")',
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({
                    Id: id
                }),
                success: function (result) {
                    if (result != null && result != "") {
                        hidMessage.val(result);
                    }
                    else {
                        alert("获取邮件内容失败！");
                    }
                },
                error: function (result) {
                    alert("获取邮件内容失败！");
                }
            });
            return false;
        });

        // 获取简历邀请模版信息
        $('.InterviewTemplate').change(function () {
            var id = $(this).val();
            if (id == "00000000-0000-0000-0000-000000000000") {
                return false;
            }
            var hidMessage = $(this).parent().parent().find('#hidInterviewBody');
            var text = hidMessage.val();
            if (text != null && text != "") {
                if (!confirm("已经有消息内容，确定要替换吗？")) {
                    return false;
                }
            }

            $.ajax({
                url: '@Url.Action("GetTemplateContent")',
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({
                    Id: id
                }),
                success: function (result) {
                    if (result != null && result != "") {
                        hidMessage.val(result);
                    }
                    else {
                        alert("获取消息内容失败！");
                    }
                },
                error: function (result) {
                    alert("获取消息内容失败！");
                }
            });
            return false;

        });

        $('#btnSave').bind('click', function () {
            $.ajax({
                url: '@Url.Action("CandidatePrviewSave")',
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({
                    Id: $('#hidId').val(),
                    JobPositionId: $('#hidJobPositionId').val(),
                    JobTitle: $('#hidJobTitle').val(),
                    Salary: $('#hidSalary').val(),
                    Welfare: $('#hidWelfare').val(),
                    Remark: $('#hidRemark').val(),
                    TagName: $('#hidTagName').val(),
                    TagId: $('#hidTagId').val(),
                }),
                success: function (result) {
                    if (result.IsSuccess) {
                        $('#hidTagId').val(result.TagId);
                        alert("保存成功！");
                    }
                    else {
                        alert("保存失败！");
                    }
                },
                error: function (result) {
                    alert("保存失败！");
                }
            });
            return false;
        });
    });
</script>
<div class="previewMain">
    <div class="resumeDetails_left">
        @using (Html.BeginForm("PrveOrNext", "Candidate", FormMethod.Post))
        {
            <div class="seeResumn">
                <p>
                    浏览简历</p>
                @Html.HiddenFor(s => Model.Keyword)
                @Html.HiddenFor(s => Model.CandidateQueryStatus)
                @Html.HiddenFor(s => Model.Type, new { id = "hidType" })
                @Html.HiddenFor(s => Model.CandidateIdList)
                <div class="change">
                    <a href="#" id="btnPrve">
                        <img src="@Url.Content("~/Content/images/arrowLeft.png")" width="11" height="16" alt="上一张" />上一张
                    </a>
                    <a href="#" id="btnNext">下一张<img src="@Url.Content("~/Content/images/arrowRight.png")" width="11" height="16" alt="下一张" /></a>
                </div>
                <div class="cr">
                </div>
                <input style="display:none" type="submit" value="上一张下一张" id="btnPrveOrNext" name="PrveOrNext" />
            </div>
        }
        @Html.Partial("~/Views/Candidate/_ReumeList.cshtml", Model.CurrentResumeItem)
    </div>
    <div class="situation">
        @Html.Partial("~/Views/Candidate/_CandidatesCase.cshtml", Model.CurrentCandidateItem)
    </div>
    @Html.Partial("~/Views/Candidate/_InterviewForm.cshtml", Model.InterviewModel)
    @Html.Partial("~/Views/Candidate/_ResumeReply.cshtml", Model.ResumeReplyModel)
    <div class="cr">
    </div>
</div>
